﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace FscNET.Client
{
    public partial class FMask : Form
    {
        private FMaskTop _top;
        private Color _bgColor = Color.Silver;
        public FMask(string message, Form parent)
        {
            InitializeComponent();
            FormBorderStyle = FormBorderStyle.None;
            BackColor = _bgColor;
            Opacity = 0.85;
            ShowInTaskbar = false;
            StartPosition = FormStartPosition.Manual;
            Size = parent.ClientSize;
            Location = parent.PointToScreen(Point.Empty);
            parent.Move += AdjustPosition;
            parent.SizeChanged += AdjustPosition;
            Shown += Form_Shown;
            _top = new FMaskTop();
            _top.Size = parent.ClientSize;
            _top.StartPosition = FormStartPosition.Manual;
            _top.Location = parent.PointToScreen(Point.Empty);
            _top.FormBorderStyle = FormBorderStyle.None;
            _top.TransparencyKey = _bgColor;
            _top.BackColor = _bgColor;
            _top.ShowInTaskbar = false;
            _top.lblMessage.Text = message;
            AddOwnedForm(_top);
        }
        private void AdjustPosition(object sender, EventArgs e)
        {
            Form parent = sender as Form;
            _top.Location = Location = parent.PointToScreen(Point.Empty);
            _top.ClientSize = ClientSize = parent.ClientSize;

        }
        private void Form_Shown(object sender, EventArgs e)
        {
            _top.Show();

        }
    }
}
